﻿using HTB.DevFx;
using Maple.Weixin.MP.Helpers;

namespace Maple.Weixin.MP.Entities.Messages
{
    public abstract class ResponseMedia
    {
        protected virtual string UploadMedia(string fileName, out string result) {
            var weixin = ObjectService.GetObject<IWeixinService>();
            var accessToken = weixin.GetAccessToken();
            string mediaId;
            result = HttpHelper.UploadMedia(accessToken, MediaType, fileName, out mediaId);
            if (!result.Contains("errorcode")) {
                result = "";
            }
            return mediaId;
        }

        protected abstract UploadMediaType MediaType { get; }
    }
}
